package com.societyGames.robotExercises
{
import com.societyGames.codeExercise.CodeExercise;

public class RobotCodeExercise extends CodeExercise
{
  public var simulation:RobotSimulation;

  //Parameters
  public function set robotStartX(value:int):void
  {
    this.simulation.robotX = value;
  }

  public function set robotStartY(value:int):void
  {
    this.simulation.robotY = value;
  }

  public function set showNumbers(value:Boolean):void
  {
    this.simulation.showNumbers = value;
  }

  public function set homeX(value:int):void
  {
    this.simulation.homeX = value;
  }

  public function set homeY(value:int):void
  {
    this.simulation.homeY = value;
  }

  public override function initialize():void
  {
    //Create the simulation
    this.simulation.initialize(this._actionQueue);
    this.addChild(this.simulation.render);
  }

  protected override function evaluateWithExceptionsHandled():void
  {
    if (this.simulation.isRobotHome)
    {
      reportSuccess();
    }
    else
    {
      reportFailure();
    }
  }
}
}